<?php
/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-6-8
 * Time: 16:29
 */

namespace app\shoes\controller;

use app\common\controller\Api;
use app\common\model\EngineerVoice;
use app\common\model\Factor;
use app\common\model\Fenorder;
use app\common\model\ProductOrder;
use app\common\model\Room as RoomModel;
use app\web\controller\Express;
use think\facade\Env;
use think\Db;


/**
 * 前台首页控制器
 * @package app\index\controller
 */
class Room extends Auth
{
    public $noNeedLogin = [
    ];




    /**
     * 获取房间详情接口
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function get_room_info () {

        if ($this->request->isPost()) {
            $data = Db::name('qt_room')->alias('room')
                ->field('room.*,rs.name as status_name')
                ->leftJoin('qt_room_status rs','room.status_id=rs.id')
                ->where(['room.store_id' => $this->userInfo['store_id'], 'room.is_deleted' => '2'])
                ->order('room.id asc')
                ->select();
            $this->result('查询成功', $data, 200);
        }
        $this->result('无效的请求', '', 204);
    }


    /**
     * 获取技师列表
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function get_engineer()
    {
        $post = $this->request->post();

        $status = isset($post['status']) ? $post['status'] : 0;
        $query = Db::name('qt_users')
            ->field('id,real_name,work_number')
            ->where('store_id', $this->userInfo['store_id']);
        if (!empty($post['group'])) {
            if ($post['group'] == 1) {
                $query->where('group', '1');
            }
            if ($post['group'] == 2) {
                $query->where('group', '2');
            }
        } else {
            $query->where('role', '3');
        }
        $query->where('status', $status);

        $userData = $query->select();
        $this->result('查询成功', $userData, 200);
    }

}
